import requests
import numpy as np
from typing import ClassVar
from .config_load import app_config
from langchain_openai import OpenAIEmbeddings
from langchain_ollama import OllamaEmbeddings




class SILICONFLOWEmbed():

    """
        初始化向量模型
    """
    EMBEDDINGS_MODEL: ClassVar[str] = app_config['siliconflow']['embed_model']
    Embed_URL: ClassVar[str]        = app_config['siliconflow']['embed_url']
    API_KEY: ClassVar[str]          = app_config['siliconflow']['api_key']
    SIMILARITY_THRESHOLD: ClassVar[float] = 0.3

    def __init__(self,similarity_threshold=0.3) -> None:

        self.embed_obj = OpenAIEmbeddings(
            openai_api_base=self.Embed_URL,
            openai_api_key=self.API_KEY,
            model=self.EMBEDDINGS_MODEL
        )

    def create_embed(self) -> object:

        return self.embed_obj
    

class OllamaEmbed():

    """
        初始化向量模型
    """
    EMBEDDINGS_MODEL: ClassVar[str] = app_config['ollama']['embed_model']


    def __init__(self) -> None:

        self.embed_obj = OllamaEmbeddings(model=self.EMBEDDINGS_MODEL)


    def create_embed(self) -> object:

        return self.embed_obj
